﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="menu_list.aspx.cs" Inherits="admin_menu_list" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body style="background-color:#dedede">
    <form id="form1" runat="server">
    <div>
        <table border="1" align=center width="80%">
            <tr align=center><td>编号</td><td>标题</td><td>状态</td><td>操作</td></tr>
            <%
                string id = Request.QueryString["id"];
                string state = "";
                if (id != null)
                {
                    if (NEWS.BLL.News.list(int.Parse(id)).Count == 0)
                    {
                        NEWS.BLL.Menu.del(int.Parse(id));

                        NEWS.JsHelper.AlertAndRedirect("删除成功！", "menu_list.aspx");
                    }
                    else {
                        NEWS.JsHelper.AlertAndRedirect("不能删除！类别下还存在新闻！", "menu_list.aspx");
                    }
                    
                }
                
                List<NEWS.Model.Menu> list = NEWS.BLL.Menu.list();
                
                for(int i=0;i<list.Count;i++)
                {
                 %>

            <tr align=center>
                <td><%=list[i].Id %></td><td><%=list[i].Title %></td>
                <td>
                    <% 
                    if (list[i].State == 1)
                    {
                        state = "正常";
                    }
                    else {
                        state = "关闭";
                    }
                         %>
                <%=state %></td>
                <td><a href="menu_add.aspx?id=<%=list[i].Id %>">编辑</a> | <a href="menu_list.aspx?id=<%=list[i].Id %>">删除</a></td>
            </tr><%} %>
        </table>
    </div>
    </form>
</body>
</html>
